package com.talent.service.auth.service.wx;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName：WxConfiguration
 * @Author: hszhou
 * @Date: 2025/1/20 11:26
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Configuration
@EnableConfigurationProperties(WxProperties.class)
public class WxConfiguration {


    private final WxProperties properties;


    public WxConfiguration(WxProperties properties) {
        this.properties = properties;
    }



    @Bean
    public WxMaService wxMaService(){

        WxMaServiceImpl wxMaService = new WxMaServiceImpl();

        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(properties.getAppId());
        config.setSecret(properties.getSecret());
        wxMaService.setWxMaConfig(config);
        return wxMaService;
    }
}
